/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
 *
 * this file licensed under the Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 * http://license.coscl.org.cn/MulanPSL2
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
 * PURPOSE.
 * See the Mulan PSL v2 for more details.
 *
 * Create: 2022-09-02
 * Description: lua mctp_transport
 */
#ifndef DEV_NCSI_ADAPTER_H
#define DEV_NCSI_ADAPTER_H

#include <stdint.h>

#define RET_OK  0
#define RET_ERR (-1)

#define LOCAL static

#define SEM_WAIT_FOREVER 0UL

#define INVALID_DATA_BYTE         0xFF
#define INVALID_DATA_WORD         0xFFFF
#define INVALID_DATA_DWORD        0xFFFFFFFF
#define INVALID_DATA_DDWORD       0xFFFFFFFFFFFFFFFF
#define INVALID_DATA_STRING       "N/A"
#define INVALID_DATA_STRING_VALUE "Unknown"
#define INVALID_UINT32            0xFFFFFFFF
#define INVALID_UINT16            0xFFFF
#define INVALID_UINT8             0xFF
#define INVALID_DATA_EMP_STR      ""

#define SENSOR_INVALID_READING       0x8000
#define SENSOR_NA_READING            0x4000
#define SENSOR_INVALID_READING_STATE 0x1000

#define ODATA_TYPE_MAX_LEN        64
#define BDF_INFO_NUM              4
#define BDF_INFO_LEN              32
#define MAX_DID_VID_LEN           32
#define MAX_PCIEPATH_LEN          256
#define OBJ_NAME_LENGTH           32
#define PROP_VAL_LENGTH           64
#define PROP_VAL_MAX_LENGTH       512
#define MAX_IP_NUM                128
#define MAX_DISK_NUM              512
#define MAX_WAIT_TIME             120
#define MAX_DYNAMIC_OBJ_NUM       128
#define MAX_INFO_LEN              248
#define MAX_SPAN_CNT              8
#define MAX_ID_LEN                4
#define OBJ_ADD_WAIT_TIME         (5 * 1000)
#define NCSI_VERSION_LEN          4
#define NET_CARD_FIRMWARE_VER_LEN 16
#define PCI_DID_VID_LEN           4

#define NET_TYPE_NONE            0 // 设置VLAN参数，不指定特定网口
#define NET_TYPE_LOM             1 // 板载1网卡，对应eth0，部分网卡支持NCSI
#define NET_TYPE_DEDICATED       2 // 专用网卡,对应eth2，不支持NCSI
#define NET_TYPE_PCIE            3 // PCIE网卡,对应eth1，部分网卡支持NCSI
#define NET_TYPE_AGGREGATION     4 // 聚合网卡，对应eth3，不支持NCSI
#define NET_TYPE_LOM2            5 // 板载2网卡,V5专用，对应eth1 ，部分网卡支持NCSI
#define NET_TYPE_INNER_DEDICATED 6 // 非对外专用网卡,不支持NCSI
#define NET_TYPE_PCIE_MGNT       7 // 板上PCIe网口，如1711芯片PCIe通道连接1822芯片外出网口，不支持NCSI
#define NET_TYPE_MEZZ_CATED      9  // mezz卡
#define NET_TYPE_OCP_CARD        10 // OCPCard, 对应eth1，与PCIe的NCSI通过开关切换
#define NET_TYPE_OCP2_CARD       11 // OCP2Card
#define NET_TYPE_MAX             12

#define QUE_WAIT_FOREVER 0xffffffff

#define BYTE_BITS_NUM 8

#define MAX_FILE_NAME_LEN   256
#define MAX_FILEPATH_LENGTH 256 /* 文件路径最大长度 */

typedef uint16_t TIMERID;

#pragma pack(1)
typedef struct {
    // 此次操作的超时时间，单位为us(毫秒)，只在读数据时有效
    // 取值范围为0~MCTP_TIMEOUT_MAX
    // MCTP_TIMEOUT_NONE表示此次操作一定要读取到数据才会返回
    unsigned int timeout;
    char*        data;
    // 在发送时，至少为MCTP_MIN_PACKET_SIZE，最多为MCTP_MAX_PACKET_SIZE
    // 在接收时，至少为MCTP_MAX_PACKET_SIZE
    unsigned int  data_len;
    unsigned char data_type;
} MCTP_DATA;
#pragma pack()

#endif // DEV_NCSI_ADAPTER_H
